using System;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace GameLib.GameSprite
{
    class ASpriteR : ASprite
    {
        public float RotateAngle
        {
            get { return rotateAngle; }
            set { rotateAngle = value; }
        }
        float rotateAngle = 0;

        public Vector2 Origin
        {
            get { return originPoint; }
            set { originPoint = value; }
        }
        Vector2 originPoint = Vector2.Zero;

        public SpriteEffects Flip
        {
            get { return flip; }
            set { flip = value; }
        }
        SpriteEffects flip = SpriteEffects.None;

        Rectangle Bound;

        public ASpriteR(Texture2D texture, Vector2 position, float rotateAngle, Vector2 originPoint)
            : base(texture, position)
        {
            this.rotateAngle = rotateAngle;
            this.originPoint = originPoint;
            Bound = new Rectangle(0, 0, Texture.Width, Texture.Height);
        }

        public ASpriteR(Texture2D texture, Vector2 position)
            : base(texture, position)
        {
            Bound = new Rectangle(0, 0, Texture.Width, Texture.Height);
        }

        public void Rotate45()
        {
            rotateAngle -= (float) (Math.PI / 4);
        }

        public override void Draw(SpriteBatch sp)
        {
            sp.Draw(Texture,
                    Position,
                    Bound,
                    Color.White,
                    rotateAngle,
                    originPoint,
                    1f,
                    flip,
                    0);
        }

        public override void Draw(SpriteBatch spriteBatch, Vector2 vPos)
        {
            spriteBatch.Draw(Texture,
                             vPos,
                             Bound,
                             Color.White,
                             rotateAngle,
                             originPoint,
                             1f,
                             flip,
                             0);
        }
    }
}
